package com.example.myapp.activities.main_activity.sectionFragments;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;
import com.example.myapp.R;

import java.util.ArrayList;

public class MonthsAdapter extends BaseAdapter {
    private LayoutInflater mInflater;
    private ArrayList<String> daty;

    public MonthsAdapter(Context context, ArrayList<String> daty) {
        mInflater = LayoutInflater.from(context);
        this.daty = daty;
    }

    @Override
    public int getCount() {
        return daty.size();
    }

    @Override
    public Object getItem(int i) {
        return daty.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        ViewHolder holder;
        if (view == null) {
                view = mInflater.inflate(R.layout.row, null);
            holder = new ViewHolder();
            holder.text = (TextView) view.findViewById(R.id.headline);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }

        holder.text.setText(daty.get(i));
        view.setBackgroundColor(Color.BLACK);

        return view;
    }

    /**
     * Widok ktory jest widoczny na liscie
     */
    public static class ViewHolder {
        TextView text;
    }
}
